Format of Entire Sound Files
Figure 1-23
illustrates an AIFF-C file that contains approximately 4.476 seconds of 8-bit monophonic sound data sampled at 22 kHz. The sound data is not compressed. Note that the number of sample frames in this example is odd, forcing a pad byte to be inserted after the sound data. This pad byte is not reflected in the
ckSize
field of the Sound Data Chunk, which means that special processing is required to correctly determine the actual chunk size.
On a Macintosh computer, the Form Chunk (and hence all the other chunks in an AIFF or AIFF-C file) is stored in the data fork of the file. The file type of an AIFF format file is
'AIFF'
, and the file type of an AIFF-C format file is
'AIFC'
. Macintosh applications should not store any information in the resource fork of an AIFF or AIFF-C file because that information might not be preserved by other applications that edit sound files.
Figure 23
A sample AIFF-C file
Every Form Chunk must contain a Common Chunk, and every AIFF-C file must contain a Format Version Chunk. In addition, if the sampled sound has a length greater than 0, there must be a Sound Data Chunk in the Form Chunk. All other chunk types are optional. Your application should be able to read all the required chunks if it uses AIFF or AIFF-C files, but it can choose to ignore any of the optional chunks.
When reading AIFF or AIFF-C files, you should keep the following points in mind:
-
Remember that the local chunks in an AIFF or AIFF-C file can occur in any order. An application that reads these types of files should be designed to get a chunk, identify it, and then process it without making any assumptions about what kind of chunk it is based on its order.
-
If your application allows modification of a chunk, then it must also update other chunks that might be based on the modified chunk. However, if there are chunks in the file that your application does not recognize, you must discard those unrecognized chunks. Of course, if your application is simply copying the AIFF or AIFF-C file without any modification, you should copy the unrecognized chunks, too.
-
You can get the clearest indication of the number of sample frames contained in an AIFF or AIFF-C file from the
numSampleFrames
parameter in the Common Chunk, not from the
ckSize
parameter in the Sound Data Chunk. The
ckSize
parameter is padded to include the fields that follow it, but it does not include the byte with a value of 0 at the end if the total number of sound data bytes is odd.
-
Remember that each chunk must contain an even number of bytes. Chunks whose total contents would yield an odd number of bytes must have a pad byte with a value of 0 added at the end of the chunk. This pad byte is not included in the
ckSize
field.
-
Remember that the
ckSize
field of any chunk does not include the first 8 bytes of the chunk (which specify the chunk type).
© 1999 Apple Computer, Inc.| Previous | Chapter contents | Chapter top | Section top | Next |